package org.wat.wcy.isi.mmazur.bp.io;

import java.util.List;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

import org.wat.wcy.isi.mmazur.bp.io.core.Database;
import org.wat.wcy.isi.mmazur.bp.io.model.BusinessProcess;
import org.wat.wcy.isi.mmazur.bp.io.model.Node;
import org.wat.wcy.isi.mmazur.bp.io.model.enums.NodeType;
import org.wat.wcy.isi.mmazur.bp.io.model.transport.BusinessProcessMatrix;
import org.wat.wcy.isi.mmazur.bp.io.model.transport.KeyValuePair;
import org.wat.wcy.isi.mmazur.bp.model.utils.ModelUtil;


@WebService(serviceName = "BPService")
@SOAPBinding
   (
         style = SOAPBinding.Style.DOCUMENT,
         use = SOAPBinding.Use.LITERAL,
         parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    )
public class BPService {

	
	public BPService() {
		
	}
	
	
	public void createModel(final String name) {
		Database.getInstance().createSchema(name);
	}

	
	public void loadModel(String name, String xpdlFileName) {
		Database.getInstance().loadModel(name, xpdlFileName);
	}

	
	public BusinessProcessMatrix getMatrix(String processName, boolean flat) {
		return Database.getInstance().getMatrix(processName, flat);
	}

	
	public List<KeyValuePair> getElementAdditionalData(String processId, String id) {
		return ModelUtil.converToKeyValue(Database.getInstance().getElementAdditionalData(processId, id));
	}

	
	public int getNextElementsCount(String processId, String id) {
		return Database.getInstance().getNextElementsCount(processId, id);
	}

	
	public List<Node> getNextElements(String processId, int i) {
		return Database.getInstance().getNextElements(processId, i);
	}

	
	public int getProcessNodesCount(String processId) {
		return Database.getInstance().getProcessNodesCount(processId);
	}

	
	public int getProcessNodesCount2(String processId, NodeType nodeType) {
		return Database.getInstance().getProcessNodesCount(processId, nodeType);
	}

	
	public String generateXpdl(String processName) {
		return Database.getInstance().getXPDL(processName);
	}

	
	public List<Node> getElementsByRole(String processId, String laneId) {
		return Database.getInstance().getElementsByRole(processId, laneId);
	}

	
	public List<Node> getPrevElements(String processId, int index) {
		return Database.getInstance().getPrevElements(processId, index);
	}

	
	public int getPrevElementsCount(String processId, String id) {
		return Database.getInstance().getPrevElementsCount(processId, id);
	}

	
	public List<BusinessProcess> getProcesses() {
		return Database.getInstance().getProcesses();
	}

	
	public List<Node> getProcessNodes(String processId) {
		return Database.getInstance().getProcessNodes(processId);
	}

	
	public Node getNode(String processId, String name) {
		return Database.getInstance().getNode(processId, name);
	}

	
	public boolean existsProcess(String name) {
		return Database.getInstance().existsProcess(name);
	}

	
	public boolean removeProcess(String id) {
		return Database.getInstance().removeProcess(id);
	}
}